package leetcode20211002;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LUYAO
 * Date: 2021-10-02
 * Time: 11:18
 */
public class ResolveMinimum {
    public static void main(String[] args) {
        int[] num = new int[5];


    }
}

class Solution2 {
    public int minArray(int[] numbers) {
        int i = 0;
        int j = numbers.length-1;
        while (i < j){
            int m = (i+j)/2;
            if(numbers[m] < numbers[j]) j = m;
            else if(numbers[m] > numbers[j]) i = m+1;
            else {
                int x = i;
                for (int k = i+1; k < j; k++) {
                    if(numbers[k] < numbers[x]){
                        x = k;
                    }
                }
                return numbers[x];
            }

        }
        return numbers[i];


    }
}
